package com.masterclient.app.modules.firstpager.fragments.contract;

import com.eoner.baselib.presenter.ThrowableConsumer;
import com.eoner.managerlibrary.netsign.NetEnvManager;
import com.masterclient.app.httpservice.RetrofitUtil;
import com.eoner.baselibrary.bean.firstpager.AllBrandBean;

import io.reactivex.Observable;
import io.reactivex.annotations.NonNull;
import io.reactivex.disposables.Disposable;
import io.reactivex.functions.Consumer;

/**
* Created by TMVPHelper on 2017/08/09
*/
public class AllBrandsPresenter extends AllBrandsContract.Presenter{

    @Override
    public void getAllBrands() {
        Observable<AllBrandBean> observable = RetrofitUtil.getInstance().getAllBrands(NetEnvManager.BASE_SURL+"1/brand/all.html");

        Disposable disposable = toSubscribe(observable, new Consumer<AllBrandBean>() {
            @Override
            public void accept(@NonNull AllBrandBean bean) throws Exception {
                if("0".equals(bean.getCode())){
                    mView.showAllBrands(bean.getData());
                }
            }
        }, new ThrowableConsumer());
        mRxManager.add(disposable);
    }



}